/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Image
} from 'react-native';

const badgeJson = require('./ios/BadgeData.json');

var {width,height,scale} =  require('Dimensions').get('window');
const clo = 3;
const boxW = 100;
const boxHMargin = (width-clo*100)/(clo+1);
const boxVMargin = 25;

class Cell extends Component {
  render() {
    return (
      <View style={styles.container}>
        {this.renderAllBadge()}
      </View>
    );
  }
  renderAllBadge(){
      const views = [];
      for (var i = 0; i < badgeJson.data.length; i++) {
         var item  =  badgeJson.data[i];
         views.push(
            <View key={i} style={styles.contentStyle}>
              <Image source={{uri:item.icon}} style={styles.imageStyle}/>
              <Text style={styles.titleStyle}>
                {item.title}
              </Text>
            </View>
         )

      }
      return views;
  }
}

const styles = StyleSheet.create({
  container: {
    flex:1,
    flexDirection:'row',
    // justifyContent:'center',
    alignItems:'center',
    // backgroundColor:'blue',
    flexWrap:'wrap',




  },
  contentStyle:{
    alignItems:'center',
    backgroundColor:'lightgray',
    height:boxW,
    width:boxW,
    marginTop:boxVMargin,
    marginLeft:boxHMargin,
    

  },
  imageStyle:{
    width:80,
    height:80

  },
  titleStyle:{
    fontSize:12
  }


});

module.exports = Cell;
